﻿using Microsoft.Xrm.Sdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DynCRMMessagingIntegration.Common
{
    public class NewCompetitorProcessor : BaseMessageProcessor
    {
        public NewCompetitorProcessor(string xmlMessage)
            :base(xmlMessage)
        {
 
        }

        public override void Execute(MessageProcessorContext context)
        {
            NewCompetitor competitor = this.XMLMessage.DeserializeObject<NewCompetitor>();

            Entity newCompetitor = new Entity("competitor");
            newCompetitor["name"] = competitor.Name;
            newCompetitor["websiteurl"] = competitor.WebSiteURL;

            context.OrganizationService.Create(newCompetitor);
        }
    }
}
